#pragma once
#include<iostream>
#include<ctime>
#include<cstdlib>

typedef void(*task_t)();//函数指针
#define Task_NUM 3      //任务个数
task_t tasks[Task_NUM]; 

void Print()
{
    std::cout << "I am print task" << std::endl;
}

void DownLoad()
{
    std::cout << "I am a download task" << std::endl;
}

void Flush()
{
    std::cout << "I am a flush task" << std::endl;
}

void DownLoadTsak()
{
    srand(time(nullptr)^666^123);
    tasks[0]=Print;
    tasks[1]=DownLoad;
    tasks[2]=Flush;
}

int SelectTask()
{
    int ret=rand()%Task_NUM;
    return ret;
}

void ExecuteTask(int number)
{
    if(number<0||number>Task_NUM-1)
    return;
    //执行任务
    tasks[number]();
}

